Refactor RhythmBlockPaletteBlocks: Extract reusable playNoteSequence helper to remove duplicated scheduling logic#5765
Conversation
|
✅ All Jest tests passed! This PR is ready to merge. |
364af2a to
202db69
Compare
|
✅ All Jest tests passed! This PR is ready to merge. |
202db69 to
1da5a4e
Compare
|
✅ All Jest tests passed! This PR is ready to merge. |
1da5a4e to
1d40d75
Compare
vanshika2720
left a comment
There was a problem hiding this comment.
@Pankajyadav919 Unrelated changes in ja.json should be removed. Please keep this PR focused .
|
✅ All Jest tests passed! This PR is ready to merge. |
|
@vanshika2720 Thank you for the review. |
|
@Pankajyadav919 still unrelated changes. |
##Summary
This PR refactors js/blocks/RhythmBlockPaletteBlocks.js by extracting duplicated setTimeout-based note scheduling logic from:
-RhythmBlock.flow
-Tuplet4Block.flow
##Problem
Both RhythmBlock and Tuplet4Block implemented nearly identical logic to:
-Loop through beat values
-Compute beat duration using bpmFactor
-Schedule notes using setTimeout
-Handle final cleanup callback
-Call tur.doWait(...)
This duplication:
-Violates DRY principles
-Makes future timing fixes harder
-Increases risk of inconsistent behavior
-Complicates testing and maintenance
##Changes
[NEW]
Add playNoteSequence(activity, beatValues, blk, turtle, bpmFactor, onComplete) helper function to centralize note scheduling logic.
Responsibilities:
-Calculate beat duration
-Schedule notes using setTimeout
-Handle final callback
-Perform tur.doWait timing synchronization